import axios from "axios";
import {
	GET,
	POST
} from "./config";
import {
	ref
} from 'vue'

const instance = axios.create({
	baseURL: import.meta.env.VITE_API, //发送请求时，会在url前拼接baseUrl
	timeout: 60*1000,
});

//封装GET POST
export function request(method, url, params,head) {
	switch (method) {
		case GET:
			return get(url, params);
		case POST:
			return post(url, params);
	}
}

function get(url, params) {
	return instance({
		url: url,
		method: "get",
		params: params,
	});
}

function post(url, data,head) {
	
	return instance({
		url: url,
		method: "post",
		data: data,
		headers: head
	});
}